package com.pox.guli.service.edu.controller.api;

import com.pox.guli.common.base.result.R;
import com.pox.guli.service.edu.entity.Teacher;
import com.pox.guli.service.edu.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author PoX21s
 * @Date: 2022/6/5 10:50
 * @Version 1.0
 */

@Api(description = "前台教师管理")
@RestController
@Slf4j
//@CrossOrigin
@RequestMapping("/api/edu/teacher")
public class ApiTeacherController {

    @Resource
    private TeacherService teacherService;

    @ApiOperation("接口测试")
    @GetMapping("/test")
    public R apiTeacherControllerTest() {
        return R.ok().message("接口测试成功");
    }

    @ApiOperation(value = "获取讲师列表")
    @GetMapping("/list")
    public R listAll() {

        List<Teacher> list = teacherService.list(null);

        return R.ok().data("items", list).message("获取讲师列表成功");
    }

    @ApiOperation(value = "根据ID返回讲师详情页")
    @GetMapping("/get/{id}")
    public R get(@ApiParam(value = "讲师ID", required = true)
                 @PathVariable String id) {

        Map<String, Object> map = teacherService.selectTeacherInfoById(id);

        return R.ok().data(map);
    }
}
